package com.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * @author wzm
 * @create 2023-07-14 10:40
 * project_name:javaweb2306
 * file:
 */
//设置过滤针对哪些路径有效
//@WebFilter("/*")
public class HelloFilter implements Filter {
    /*初始化*/
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    /*过滤器中执行过滤操作的方法*/
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
     //通常在这里进行一些判断和处理  满足条件才放行
        System.out.println("放行前我处理了一些内容");

        //放行
       filterChain.doFilter(servletRequest,servletResponse);

        System.out.println("请求之后要做了一些操作");

    }

    //销毁
    @Override
    public void destroy() {
    }
}
